package main

import (
	"fmt"

	"github.com/gin-gonic/gin"

	"com.wen/dal/db"

	"com.wen/controller"

	"github.com/DeanThompson/ginpprof"
)

func main() {
	//获取gin提供的微服务
	router := gin.Default()
	//数据库连接
	dns := "root:123456@tcp(localhost:3306)/wencs?parseTime=true"
	err := db.Init(dns)
	if err != nil {
		panic(err)

	}

	fmt.Println("数据库连接成功")
	ginpprof.Wrapper(router)
	router.Static("/static/", "./static")
	router.LoadHTMLGlob("views/*")
	router.GET("/", controller.IndexHandle)

	//文章详情页
	router.GET("/article/detail/", controller.ArticleDetail)

	router.GET("/article/new/", controller.NewArticle)

	//文章提交接口
	router.POST("/article/submit/", controller.ArticleSubmit)

	router.Run(":1233")

}
